//创建线程的方法4：通过匿名内部类，实现Runnable，重写run，调用start  （和2没什么区别，4这样写的目的是简化代码
//4
public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable=new Runnable() {
            @Override
            public void run() {
                while(true){
                    System.out.println("hello 匿名 Runnable!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        Thread t=new Thread(runnable);
        t.start();

        while(true){
            System.out.println("hello main!");
            Thread.sleep(1000);
        }
    }
}
